﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Media;


namespace MEMORY
{
  
    public class MyPictureBox
    {
        public PictureBox pb;
     //   public int id; //мб и не надо совсем
        public Image img_in_box; //картинка, которая будет меняться
        public int click_amount = 0;
       
        public bool opened;

        public MyPictureBox(int x, int y)
        {
            pb = new PictureBox();
            pb.Name = "pic";
            pb.Location=  new Point(x, y);
            pb.Width = 80;
            pb.Height = 80;

            pb.BackgroundImage = MEMORY.Properties.Resources.memory; // задаем по умолчанию рубашку
        }
        public void ImageIn(Image img)
        {
            img_in_box = img;
    
        }
        public void ImageMem()
        {
            pb.BackgroundImage = MEMORY.Properties.Resources.memory; // задаем по умолчанию рубашку
        }
        public void Show(Form1 a)
        {
            a.Controls.Add(pb);           
        }
        public void Delete(Form1 a)
        {
            a.Controls.Remove(pb);
        }

        public void playSound_flip(bool flag)
        {
            if (flag == true)
            {
                SoundPlayer flipCard1 = new SoundPlayer();
                flipCard1.Stream = MEMORY.Properties.Resources.flipCard;
                flipCard1.Play();
            }
            flag = false;
        }

        public void Click()
        {           
            pb.Click +=new EventHandler(pb_Click);
        }

        private void pb_Click(object sender, EventArgs e)
        {            
            if (MEMORY_NEW.Global.Click_Flag < 2)
            {
                opened = true;
                playSound_flip(MEMORY_NEW.Global.Sound_Flag); // звук переворачивания карты
                pb.BackgroundImage = img_in_box;
            }
            MEMORY_NEW.Global.Click_Flag++;  

              if (MEMORY_NEW.Global.Click_Flag == 2)
              {
                  MEMORY_NEW.Global.time1.Enabled = true;
              }
            
        }
    }

    public class MyBitmap
    {
        public Bitmap bm;
        public int id1;
        public int id2;

        public MyBitmap(Image img)
        {
            bm = new Bitmap(img);          
        }
            
    }
   
}

 